package com.dsbj.it.DingTalkBotStarter.common.result;

import lombok.Getter;

/**
 * 统一返回结果码
 */
@Getter
public enum ResultCode {
    
    SUCCESS(200, "操作成功"),
    ERROR(500, "操作失败"),
    VALIDATE_FAILED(400, "参数检验失败"),
    UNAUTHORIZED(401, "暂未登录或token已经过期"),
    FORBIDDEN(403, "没有相关权限"),
    NOT_FOUND(404, "请求的资源不存在"),
    METHOD_NOT_ALLOWED(405, "请求方法不允许"),
    CONFLICT(409, "请求冲突"),
    UNSUPPORTED_MEDIA_TYPE(415, "不支持的媒体类型"),
    TOO_MANY_REQUESTS(429, "请求过于频繁"),
    INTERNAL_SERVER_ERROR(500, "服务器内部错误"),
    SERVICE_UNAVAILABLE(503, "服务不可用"),
    
    // 业务相关错误码
    USER_NOT_FOUND(1001, "用户不存在"),
    USERNAME_ALREADY_EXISTS(1002, "用户名已存在"),
    PASSWORD_INCORRECT(1003, "密码错误"),
    ACCOUNT_DISABLED(1004, "账户已被禁用"),
    TOKEN_EXPIRED(1005, "令牌已过期"),
    TOKEN_INVALID(1006, "令牌无效"),
    
    // SQL注入相关错误码
    SQL_INJECTION_DETECTED(2001, "检测到SQL注入攻击"),
    DANGEROUS_CHARACTER_DETECTED(2002, "检测到危险字符"),
    SUSPICIOUS_SQL_OPERATION(2003, "可疑的SQL操作"),
    
    // 文件相关错误码
    FILE_UPLOAD_FAILED(3001, "文件上传失败"),
    FILE_NOT_FOUND(3002, "文件不存在"),
    FILE_SIZE_EXCEEDED(3003, "文件大小超出限制"),
    FILE_TYPE_NOT_ALLOWED(3004, "文件类型不允许"),
    
    // 数据库相关错误码
    DATABASE_ERROR(4001, "数据库操作失败"),
    DATA_NOT_FOUND(4002, "数据不存在"),
    DATA_ALREADY_EXISTS(4003, "数据已存在"),
    DATA_INTEGRITY_VIOLATION(4004, "数据完整性约束违反"),
    
    // 系统相关错误码
    SYSTEM_ERROR(5001, "系统错误"),
    CONFIGURATION_ERROR(5002, "配置错误"),
    EXTERNAL_SERVICE_ERROR(5003, "外部服务错误"),
    NETWORK_ERROR(5004, "网络错误");
    
    private final Integer code;
    private final String message;
    
    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
}
